<%@ page import="java.util.Enumeration" %>
<%--
  Created by IntelliJ IDEA.
  User: seth.yang
  Date: 12-4-25
  Time: ??11:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isErrorPage="true" %>
<html>
<head>
    <title>Simple jsp page</title>
    <style type="text/css">
        * {font-size:12px; font-family:"Microsoft Yahei" monospace;}
        table {width: 100%; border:none; border-collapse:collapse;}
        th {padding: 3px; border:1px solid #999; text-align:center;background-color:#ccc}
        td {padding: 3px; border:1px solid #999}
        h6 {margin-top: 30px; margin-bottom:0; font-weight:normal;}
    </style>
</head>
<body onload="alert (&#34;abc&#34;)">
<form action="env.jsp" method="post">
    <input type="submit" value="submit" />
</form>
Servlet Context:
<table>
    <tr>
        <th>name</th>
        <th>type</th>
        <th>content</th>
    </tr>
<%
    Enumeration<String> e = application.getAttributeNames ();
    for (; e.hasMoreElements ();) {
        String key = e.nextElement ();
        Object value = application.getAttribute (key);
%>
    <tr>
        <td><%= key%></td>
        <td><%= value.getClass ().getName ()%></td>
        <td><%= value%></td>
    </tr>
<%
    }
%>
</table>
<h6>Http Header</h6>
<table>
    <tr>
        <th>name</th>
        <th>content</th>
    </tr>
<%
    e = request.getHeaderNames ();
    for (; e.hasMoreElements ();) {
        String key = e.nextElement ();
        Enumeration<String> h = request.getHeaders (key);
        StringBuilder builder = new StringBuilder ();
        for (; h.hasMoreElements (); ) {
            if (builder.length () > 0) builder.append ("<br/>");
            builder.append (h.nextElement ());
        }
if ("user-agent".equals (key))
                System.out.println (builder);

//        java.net.Socket socket = null;
//        socket.getLocalAddress ().
%>
    <tr>
        <td><%= key%></td>
        <td><%= builder%></td>
    </tr>
<%
    }
%>
</table>
<h6>Http Request</h6>
<table>
    <tr>
        <th>name</th>
        <th>type</th>
        <th>content</th>
    </tr>
<%
    e = request.getAttributeNames ();
    for (; e.hasMoreElements ();) {
        String key = e.nextElement ();
        Object value = request.getAttribute (key);
%>
    <tr>
        <td><%= key%></td>
        <td><%= value.getClass ().getName ()%></td>
        <td><%= value%></td>
    </tr>
<%
    }
%>
</table>
<h6>aaaa</h6>
remote addr = <%=request.getRemoteAddr ()%><br />
remote host = <%=request.getRemoteHost ()%><br />
</body>
</html>